
var xmlHttp;
function getOs()     
    {     
       var OsObject = "";     
       if(navigator.userAgent.indexOf("MSIE")>0) {     
            return "MSIE";       //IE浏览器  
       }  
       if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){     
            return "Firefox";     //Firefox浏览器  
       }  
       if(isSafari=navigator.userAgent.indexOf("Safari")>0) {     
            return "Safari";      //Safan浏览器  
       }  
       if(isCamino=navigator.userAgent.indexOf("Camino")>0){     
            return "Camino";   //Camino浏览器  
       }  
       if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){     
            return "Gecko";    //Gecko浏览器  
       }     
    }   

function createXMLHttpRequest() {
	
	var btype=getOs();  
    if(btype!="Firefox"){  
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
    }else{  
        xmlHttp =new XMLHttpRequest();  
    }  
}
function hide(s) {
	document.getElementById(s).style.display = document.getElementById(s).style.display == "none" ? "" : "none";
}
function reload() {
	location.reload();
}
function selectAll() {
	if (document.all.chk.length != undefined) {
		for (i = 0; i < document.all.chk.length; i++) {
			document.all.chk[i].checked = document.all.select.checked;
		}
	} else {
		document.all.chk.checked = document.all.select.checked;
	}
}
function querypage(url) {
	if (document.forms[0] == null) {
		location.href = url;
	} else {
		document.forms[0].action = url;
		document.forms[0].submit();
	}
}
function isDigit(s) {
	var patrn = /^[0-9]{1,20}$/;
	if (!patrn.exec(s)) {
		return false;
	}
	return true;
}
function insertItem(url) {
	location.href = url;
}
function updateItem(url) {
	location.href = url;
}
function goDelete(para) {
	if (confirm("\u771f\u7684\u8981\u5220\u9664\u5417\uff1f")) {
		var url = "";
		var num = 0;
		if (document.all.chk.length && document.all.chk.length != undefined) {
			for (i = 0; i < document.all.chk.length; i++) {
				if (document.all.chk[i].checked == true) {
					url = url + "&id=" + document.all.chk[i].value;
					num++;
				}
			}
			if (num > 0) {
				url = para + "?type=p" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("请选择删除项");
			}
		} else {
			url = "&id=" + document.all.chk.value;
			if (document.all.chk.checked == true) {
				url = para + "?type=d" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("\u8bf7\u9009\u62e9\u8981\u5220\u9664\u7684\u83dc\u5355\u9879!");
			}
		}
	}
}

function goSubmit(para) {
	if (confirm("确认要提交吗?")) {
		var url = "";
		var num = 0;
		if (document.all.chk.length && document.all.chk.length != undefined) {
			for (i = 0; i < document.all.chk.length; i++) {
				if (document.all.chk[i].checked == true) {
					url = url + "&id=" + document.all.chk[i].value;
					num++;
				}
			}
			if (num > 0) {
				url = para + "?type=p" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("请选择提交项");
			}
		} else {
			url = "&id=" + document.all.chk.value;
			if (document.all.chk.checked == true) {
				url = para + "?type=d" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("请选择提交项");
			}
		}
	}
}


function goEditor(para) {
	if (confirm("确认要修改吗?")) {
		var url = "";
		var num = 0;
		if (document.all.chk.length && document.all.chk.length != undefined) {
			for (i = 0; i < document.all.chk.length; i++) {
				if (document.all.chk[i].checked == true) {
					url = url + "&id=" + document.all.chk[i].value;
					num++;
				}
			}
			if (num > 0) {
				url = para + "?type=p" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("请选择修改项");
			}
		} else {
			url = "&id=" + document.all.chk.value;
			if (document.all.chk.checked == true) {
				url = para + "?type=d" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("请选择修改项");
			}
		}
	}
}

function goReturn(para) {
	if (confirm("确认要驳回吗?")) {
		var url = "";
		var num = 0;
		if (document.all.chk.length && document.all.chk.length != undefined) {
			for (i = 0; i < document.all.chk.length; i++) {
				if (document.all.chk[i].checked == true) {
					url = url + "&id=" + document.all.chk[i].value;
					num++;
				}
			}
			if (num > 0) {
				url = para + "?type=p" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("请选择提交项");
			}
		} else {
			url = "&id=" + document.all.chk.value;
			if (document.all.chk.checked == true) {
				url = para + "?type=d" + url;
				document.forms[0].action = url;
				document.forms[0].submit();
			} else {
				alert("请选择提交项");
			}
		}
	}
}
//王震2011-08-28,过滤特殊字符串
function checkStr(str)      
{    
      var patrn =/^[^\|"'<>]*$/;
	  var str2="";   
	  for(var i = 0; i < str.length; i ++)      
	 {            
	   if(str.substr(i,1).match(/^(-|\+)?\d+$/)) 
	   {
		 str2 = str2+str.substr(i,1);   
	   }    
            
      } 
	  return str2;
} 

function gotopage(url, total, urlgo) {
	var capage = document.all.gotopage.value;
	if (!isDigit(capage)) {
		document.all.gotopage.value = "";
		return;
	}
	if (parseInt(capage) > parseInt(total)) {
		capage = total;
	}
	if (capage < 1) {
		capage = 1;
	}
	if (document.forms[0] == null) {
		location.href = url + "cpage=" + capage + "&total=" + total + "&url=" + urlgo;
	} else {
		document.forms[0].action = url + "cpage=" + capage + "&total=" + total + "&url=" + urlgo;
		document.forms[0].submit();
	}
}
//使用透明帧显示忙信息，并屏蔽用户操作
function showBusyMsg(msg) {
	window.document.all.MsgText.innerHTML = msg;
	window.document.all.BusyMsg.style.display = "";
	window.document.all.BusyDiv.style.display = "";
}
function handleStateChange() {
	var img = "<div id='loading'><div class='loading-indicator'><table align='center'><tr>\u9875\u9762\u6b63\u5728\u5904\u7406\u4e2d...<img src='images/loading.gif'></tr></table></div>";
	
	if(xmlHttp.readyState==4)
	{
		if (xmlHttp.status == 200) {
			document.getElementById("data").innerHTML = xmlHttp.responseText;
		}
	}
	else {
		document.getElementById("data").innerHTML = img;
	}
}

